<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Yep
  Date: 2023/11/20
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link
            href="${path }/resources/css/plugins/bootstrap-table/bootstrap-table.min.css"
            rel="stylesheet">
    <link href="${path }/resources/css/animate.css" rel="stylesheet">
    <link href="${path }/resources/css/style.css?v=4.1.0" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/resources/js/jquery-1.8.3.js"></script>
</head>
<body>
欢迎您：<span style="color: red">${currentUser.username}</span></a><br>
<form action="" method="post" id="fms">
    姓名：<input type="text" name="name" value="${stuVo.name}">
    生日： <input placeholder="开始时间" id="txt_search_start" name="start" type="date"
                 value='<fmt:formatDate pattern="yyyy-MM-dd" value="${stuVo.start}"></fmt:formatDate>'/>
    <input placeholder="结束时间" id="txt_search_end" name="end" type="date"
           value='<fmt:formatDate pattern="yyyy-MM-dd" value="${stuVo.end}"></fmt:formatDate>'/>
    专业：<select name="mid">
    <option value="">--请选择--</option>
    <c:forEach items="${majorList}" var="m">
        <option value="${m.id}" <c:if test="${m.id==stuVo.mid}">selected</c:if>>${m.mname}</option>
    </c:forEach>
</select>
    老师：<select name="tid">
    <option value="">--请选择--</option>
    <c:forEach items="${teacherList}" var="t">
        <option value="${t.id}" <c:if test="${t.id==stuVo.tid}">selected</c:if>>${t.tname}</option>
    </c:forEach>
</select>
    <input type="button" value="搜索" id="btnSearch">
</form>

<button id="up" class="btn btn-info" data-toggle="modal" data-target="#editModal">添加</button>
<button id="deletes" class="btn btn-danger" style="margin-left:10px;">批量删除</button>
<button id="update" class="btn btn-danger" style="margin-left:10px;">修改</button>
<button id="count" class="btn btn-info" data-toggle="modal" data-target="#editModal">报表</button>
<button id="out" class="btn btn-danger" style="margin-left:10px;">导出</button>
<button id="importExcel" class="btn btn-danger" style="margin-left:10px;">导入</button>

<form action="deleteStu" id="formSubmit">
    <table border="1">
        <tr>
            <td><input type="checkbox"></td>
            <td>编号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>生日</td>
            <td>专业</td>
            <td>老师</td>
            <td>录入日期</td>
            <td>审核状态</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageInfo.list}" var="vo">
            <tr>
                <td>
                    <input type="checkbox" class="fen" name="id" value="${vo.id}">
                </td>
                <td>${vo.id}</td>
                <td>${vo.name}</td>
                <td>${vo.sex}</td>
                <td><fmt:formatDate pattern="yyyy-MM-dd" value="${vo.birthday}"></fmt:formatDate></td>
                <td>${vo.mname}</td>
                <td>${vo.tname}</td>
                <td><fmt:formatDate pattern="yyyy-MM-dd" value="${vo.joindate}"></fmt:formatDate></td>
                <td>
                    <c:if test="${vo.status=='0'}">待审核</c:if>
                    <c:if test="${vo.status=='1'}">审核通过</c:if>
                    <c:if test="${vo.status=='2'}">审核不通过</c:if>
                </td>
                <td>
                    <a href="findShow?id=${vo.id}">详情</a>
                    <c:if test="${vo.status=='0'}"><a href="updateStatus?id=${vo.id}&status=1">审批通过</a></c:if>
                    <c:if test="${vo.status=='0'}"><a href="updateStatus?id=${vo.id}&status=2">审批不通过</a></c:if>


                </td>
            </tr>
        </c:forEach>
    </table>
</form>
第${pageInfo.pageNum}页/共${pageInfo.pages}页/共${pageInfo.total}条
<input type="button" value="首页" onclick="jump(${pageInfo.firstPage})">
<input type="button" value="上一页" onclick="jump(${pageInfo.prePage})">
<input type="button" value="下一页" onclick="jump(${pageInfo.nextPage})">
<input type="button" value="尾页" onclick="jump(${pageInfo.lastPage})">


<!--导入-->
<div class="modal fade" id="modal_import" role="dialog" aria-labelledby="modal_employee_import" hidden
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form id="form_import" method="post" action="importXxx" enctype="multipart/form-data">
                    <table style="border-collapse:separate; border-spacing:0px 10px;">
                        <tr>
                            <td>请选择文件：</td>
                            <td colspan="4">
                                <input type="file" name="importfile" id="importFile"
                                       class="form-control" aria-required="true" required/>
                            </td>
                        </tr>
                    </table>

                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary" id="submit_form_employee_btn">保存</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script>
    $("#btnSearch").click(function () {
        $("#fms").attr("action", "findLimit").submit()
    })

    function jump(pageNum) {
        $("#fms").attr("action", "findLimit?pageNum=" + pageNum).submit()
    }

    // 新增按钮
    $("#up").click(function () {
        location.href = "findAdd"
    });
    //导入弹框
    $("#importExcel").click(function () {
        $("#modal_import").show();
    });
    //统计
    $("#count").click(function () {
        location.href = "findCount";
    });

    //导出
    $("#out").click(function () {
        location.href = "outStu";
    });
    //批量删除
    $("#deletes").click(function () {
        //下面复选框被选中的长度大于0
        if ($(".fen:checked").length > 0) {//可以删除
            //判断要不要删除
            if (confirm("您确定要删除吗?")) {
                //提交id=formSubmit的表单的信息
                $("#formSubmit").submit();
            }
        } else {
            alert("至少选择一条删除");
        }

    });

    //回显
    $("#update").click(function () {

        if ($(".fen:checked").length == 1) {
            $("#formSubmit").attr("action", "findUpdate").submit()
        } else {
            alert("请选择一条数据");
        }

    });
</script>
</body>
</html>
